
cc.game.onStart = function(){

    cc.view.enableRetina(cc.sys.os === cc.sys.OS_IOS ? true : false);
    cc.view.adjustViewPort(true);
    cc.view.setDesignResolutionSize(960, 640, cc.ResolutionPolicy.FIXED_HEIGHT);
    cc.view.resizeWithBrowserSize(true);
    cc.loader.resPath = 'res';
    cc.LoaderScene.preload(g_resources, function () {
            onConnect = function()
            {   
                dblLoginScene.runThisScene()
            }
            ioSocket.connect(onConnect)
    }, this)
}

cc.game.run()

createNameEditBox = function(inputBox, placeHolder, maxLength)
{   
    maxLength = maxLength || 8
    //editbox
    var editBoxSize = cc.size(inputBox.getContentSize().width-30, 40)
    var editBox  = cc.EditBox.create(editBoxSize, cc.Scale9Sprite.create())
    editBox.setPosition(15, inputBox.getContentSize().height / 2)
    editBox.setFontSize(30)
    editBox.setPlaceHolder(placeHolder)
    editBox.setMaxLength(maxLength)
    editBox.setAnchorPoint(cc.p(0, 0.5))
    editBox.setFontColor(cc.color(63, 51, 43, 255) )
    editBox.setPlaceholderFontColor(cc.color(63, 51, 43, 255) )
    editBox.setPlaceholderFontSize(30)
    editBox.setReturnType(cc.KEYBOARD_RETURNTYPE_DONE)
    editBox.setInputMode(cc.EDITBOX_INPUT_MODE_SINGLELINE)
    inputBox.addChild(editBox)

    //Handler
    var handler = {
        editBoxEditingDidBegin: function (editBox) {
            cc.log("editBox editBoxEditingDidBegin");
        },
        editBoxEditingDidEnd: function (editBox) {
            cc.log("editBox editBoxEditingDidEnd");
        },

        editBoxTextChanged: function (editBox, text) {
            cc.log("editBox editBoxTextChanged:",text,editBox.getString());
            inputBox.data = editBox.getString()
        },
        editBoxReturn: function (editBox) {
            cc.log("editBox editBoxReturn");
        },
    }
    editBox.setDelegate(handler)
}



ShowTipsTTF = function(args)
{
    var str = args.str
    var parent = args.parent || cc.director.getRunningScene()
    var pos = args.pos || {x:cc.director.getWinSize().width * 0.5, y:cc.director.getWinSize().height * 0.7} 
    var color = args.color || cc.color(242, 169, 123, 255) 
    var size = args.size || 40
    var label = cc.LabelTTF.create(str, "Helvetica", size)
    label.setFontFillColor(color)
    label.setPosition(cc.p(pos.x, pos.y))
    // label.align(cc.p(0.5, 0.5), pos.x, pos.y)
    //     :addTo(parent)
    parent.addChild(label)    

    var seq = cc.sequence(cc.FadeOut.create(3),cc.callFunc(function(){this.removeFromParent()},label))
    label.runAction(seq)
}




